<template>
  <div class="processRecord">
    <p-table
      size="middle"
      bordered
      :pagination="false"
      :columns="columns"
      :scroll="{x:1300}"
      :data-source="tableData"
    >
      <template slot="scientificType" slot-scope="text">
        <span>{{text === '1'?'单盘贴片外协加工':'厂内科研工单'}}</span>
      </template>
      <template slot="imgSlot" slot-scope="text">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
        <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
      </template>
      <template slot="fileSlot" slot-scope="text">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
        <p-button
          v-else
          :ghost="true"
          type="primary"
          icon="download"
          size="small"
          @click="uploadFile(text)">
          下载
        </p-button>
      </template>
    </p-table>
  </div>
</template>
<script>
import process from "@/api/process";
import moment from "moment";
const columns = [
  {
    title: "任务编号",
    align: "center",
    width: 180,
    dataIndex: "scientificOrder",
  },
  {
    title: "申请人",
    align: "center",
    width: 180,
    dataIndex: "scientificPlease",
  },
  {
    title: "部门名称",
    align: "center",
    width: 180,
    dataIndex: "dptno",
    customRender: (text) => {
      if (!text) {
        return "";
      } else {
        return text;
      }
    },
  },
  {
    title: "联系方式",
    align: "center",
    width: 180,
    dataIndex: "scientificContact",
  },
  {
    title: "项目编码",
    align: "center",
    width: 180,
    dataIndex: "scientificno",
  },
  {
    title: "项目名称",
    align: "center",
    width: 180,
    dataIndex: "scientificname",
  },
  {
    title: "加工类型",
    align: "center",
    width: 180,
    dataIndex: "scientificType",
    scopedSlots: { customRender: "scientificType" },
  },
  {
    title: "名称",
    align: "center",
    width: 180,
    dataIndex: "name",
  },
  {
    title: "需求完成时间",
    align: "center",
    width: 180,
    dataIndex: "contentTime",
    customRender: (text) => {
      return text ? moment(text).format("YYYY-MM-DD") : "--";
    },
  },
  {
    title: "型号/图号（版号）",
    align: "center",
    width: 180,
    dataIndex: "model",
  },
  {
    title: "计划开始时间",
    align: "center",
    width: 180,
    dataIndex: "scientificStarttime",
    customRender: (text) => {
      return text ? moment(text).format("YYYY-MM-DD") : "--";
    },
  },
  {
    title: "实际物料齐套时间",
    align: "center",
    width: 180,
    dataIndex: "scientificQitime",
    customRender: (text) => {
      return text ? moment(text).format("YYYY-MM-DD") : "--";
    },
  },
  {
    title: "当前状态",
    align: "center",
    width: 180,
    dataIndex: "status",
    customRender: (text) => {
      return text === -1
        ? "完成"
        : text === 0
        ? "待提交"
        : text === 1
        ? "审批中"
        : text === 2
        ? "待工艺评审"
        : text === 3
        ? "待工艺给出供应商建议"
        : text === 4
        ? "待采购评审"
        : text === 5
        ? "待需求发布"
        : "其他";
    },
  },
  {
    title: "BOMreport",
    align: "center",
    width: 180,
    dataIndex: "bomReport",
    scopedSlots: { customRender: "fileSlot" },
  },
  {
    title: "科研bom表",
    align: "center",
    width: 180,
    dataIndex: "researchBom",
    scopedSlots: { customRender: "fileSlot" },
  },
  {
    title: "附件",
    align: "center",
    width: 180,
    dataIndex: "accessory",
    scopedSlots: { customRender: "fileSlot" },
  },
  // {
  //   title: "创建人",
  //   align: "center",
  //   width: 180,
  //   dataIndex: "createBy",
  // },
  // {
  //   title: "创建日期",
  //   align: "center",
  //   dataIndex: "createTime",
  //   width: 180,
  //   customRender: (text) => {
  //     return text ? moment(text).format("YYYY-MM-DD") : "--";
  //   },
  // },
  // {
  //   title: "更新人",
  //   align: "center",
  //   width: 180,
  //   dataIndex: "updateBy",
  // },
  // {
  //   title: "更新日期",
  //   align: "center",
  //   width: 180,
  //   dataIndex: "updateTime",
  //   customRender: (text) => {
  //     return text ? moment(text).format("YYYY-MM-DD") : "--";
  //   },
  // },
];

export default {
  inject: ["processInstanceId", "taskId"],
  data() {
    return {
      columns,
      moment,
      readStatusMap: {
        1: "未读",
        2: "已读",
      },
      windowSize: true,
      tableData: [
        /* {
          startTime: '创建时间',
          endTime: '处理时间',
          activityName: '节点名称',
          assigneeName: '执行人',
          readStatus: '1',
          operator: 'operator',
          comment: '处理意见',
        } */
      ],
      tableHeight: "450",
    };
  },
  computed: {},
  methods: {
    getList() {
      this.tableData = []
      process.getExampleBusiness(this.processInstanceId).then((res) => {
        this.tableData.push(res.data);
      });
    },
  },
  mounted() {
    this.getList();
  },
};
</script>
<style lang="less">
.processRecord {
  overflow: hidden;
  .handing {
    color: #409efd;
  }
  .title-line {
    font-size: 16px;
    margin: 30px 0 10px 0;
  }
}
</style>
